import request from './request'

/**
 * 配置预设 API
 */

// ========== 应用管理 ==========
// 获取应用列表
export const getApplications = (params) => {
  return request({
    url: '/applications',
    method: 'get',
    params
  })
}

// 获取应用详情
export const getApplication = (id) => {
  return request({
    url: `/applications/${id}`,
    method: 'get'
  })
}

// 创建应用
export const createApplication = (data) => {
  return request({
    url: '/applications',
    method: 'post',
    data
  })
}

// 更新应用
export const updateApplication = (id, data) => {
  return request({
    url: `/applications/${id}`,
    method: 'put',
    data
  })
}

// 删除应用
export const deleteApplication = (id) => {
  return request({
    url: `/applications/${id}`,
    method: 'delete'
  })
}

// ========== OBS桶配置预设 ==========
// 获取OBS桶配置预设列表
export const getObsBucketPresets = (params) => {
  return request({
    url: '/config-presets/obs-buckets',
    method: 'get',
    params
  })
}

// 获取OBS桶配置预设详情
export const getObsBucketPreset = (id) => {
  return request({
    url: `/config-presets/obs-buckets/${id}`,
    method: 'get'
  })
}

// 创建OBS桶配置预设
export const createObsBucketPreset = (data) => {
  return request({
    url: '/config-presets/obs-buckets',
    method: 'post',
    data
  })
}

// 更新OBS桶配置预设
export const updateObsBucketPreset = (id, data) => {
  return request({
    url: `/config-presets/obs-buckets/${id}`,
    method: 'put',
    data
  })
}

// 删除OBS桶配置预设
export const deleteObsBucketPreset = (id) => {
  return request({
    url: `/config-presets/obs-buckets/${id}`,
    method: 'delete'
  })
}

// ========== 资源池配置预设 ==========
// 获取资源池配置预设列表
export const getResourcePoolPresets = (params) => {
  return request({
    url: '/config-presets/resource-pools',
    method: 'get',
    params
  })
}

// 获取资源池配置预设详情
export const getResourcePoolPreset = (id) => {
  return request({
    url: `/config-presets/resource-pools/${id}`,
    method: 'get'
  })
}

// 创建资源池配置预设
export const createResourcePoolPreset = (data) => {
  return request({
    url: '/config-presets/resource-pools',
    method: 'post',
    data
  })
}

// 更新资源池配置预设
export const updateResourcePoolPreset = (id, data) => {
  return request({
    url: `/config-presets/resource-pools/${id}`,
    method: 'put',
    data
  })
}

// 删除资源池配置预设
export const deleteResourcePoolPreset = (id) => {
  return request({
    url: `/config-presets/resource-pools/${id}`,
    method: 'delete'
  })
}

// ========== 镜像配置预设 ==========
// 获取镜像配置预设列表
export const getImagePresets = (params) => {
  return request({
    url: '/config-presets/images',
    method: 'get',
    params
  })
}

// 获取镜像配置预设详情
export const getImagePreset = (id) => {
  return request({
    url: `/config-presets/images/${id}`,
    method: 'get'
  })
}

// 创建镜像配置预设
export const createImagePreset = (data) => {
  return request({
    url: '/config-presets/images',
    method: 'post',
    data
  })
}

// 更新镜像配置预设
export const updateImagePreset = (id, data) => {
  return request({
    url: `/config-presets/images/${id}`,
    method: 'put',
    data
  })
}

// 删除镜像配置预设
export const deleteImagePreset = (id) => {
  return request({
    url: `/config-presets/images/${id}`,
    method: 'delete'
  })
}

// ========== NAS配置预设 ==========
// 获取NAS配置预设列表
export const getNasPresets = (params) => {
  return request({
    url: '/config-presets/nas',
    method: 'get',
    params
  })
}

// 获取NAS配置预设详情
export const getNasPreset = (id) => {
  return request({
    url: `/config-presets/nas/${id}`,
    method: 'get'
  })
}

// 创建NAS配置预设
export const createNasPreset = (data) => {
  return request({
    url: '/config-presets/nas',
    method: 'post',
    data
  })
}

// 更新NAS配置预设
export const updateNasPreset = (id, data) => {
  return request({
    url: `/config-presets/nas/${id}`,
    method: 'put',
    data
  })
}

// 删除NAS配置预设
export const deleteNasPreset = (id) => {
  return request({
    url: `/config-presets/nas/${id}`,
    method: 'delete'
  })
}
